#!/bin/bash

# Exit if any command fails
set -e

# Check for changes that are not yet committed to git
if [[ -n $(git status -s) ]]; then
  echo "There are changes that are not committed yet."
  exit 1
fi

# Pull the latest changes
git pull origin main

# Install dependencies
npm install

# Run build script
npm run build

# Automatically bump the patch version and tag it in Git
npm version patch

# Push the new version and tags to Git
git push && git push --tags

# Publish the package to npm
npm publish

echo "Package published successfully."
